# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html


# useful for handling different item types with a single interface
from itemadapter import ItemAdapter
import pymongo
from pymongo.collection import Collection#更容易区mongo里的数据表
class Connect_mongo(object):
    def __init__(self):
        self.client=pymongo.MongoClient("mongodb://user_spider:pq888888@192.168.136.128:27017/?authSource=spider")
        self.db_data=self.client['spider']
    def insert_item(self,item):
        db_collection=Collection(self.db_data,'MyabandonwareCategorfornameisnull')
        db_collection.insert_one(item)
mongo_info=Connect_mongo()

class MyabandonwarePipeline:
    def process_item(self, item, spider):
        print('this is MyabandonwarePipeline',item)
        mongo_info = Connect_mongo()
        mongo_info.insert_item(dict(item))